package com.example.suntest.service2;

import com.example.suntest.entity.User;
import com.example.suntest.entity.UserDTO;
import com.example.suntest.service.AbstractPushDownConverter;
import com.example.suntest.service2.PushDownConverter;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @version 1.0
 * @Package: com.example.suntest.service
 * @ClassName: PushDownConverterUserToUserDTO
 * @Author: sgq
 * @Date: 2024/7/10 16:17
 * @Description: TODD
 */

public class UserToUserDTOPushDownConverter implements PushDownConverter<User, UserDTO> {

    @Override
    public UserDTO convert(User source) {
        UserDTO userDTO = new UserDTO();
        userDTO.setId(source.getId());
        userDTO.setName(source.getName()+"-DTO");
        userDTO.setPassword(source.getPassword()+"-DTO");
        return userDTO;
    }
    @Override
    public List<UserDTO> batchConvert(List<User> sources) {
        List<UserDTO> userDTOList = sources.stream().map(this::convert).collect(Collectors.toList());
        return userDTOList;
    }


}
